﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using Top.Web.Api;
using Top.PointStore.Business;
using Top.PointStore.LuckTurntable;
using Top.Web.Api.Filters;
using Top.Web;
using Top.Core;
//using Top.PointStore.Filters;

namespace Top.PointStore.Controllers
{
    public class DemoController : ApiBase
    {
        public DemoController()
            : base()
        {

        }
        //[HttpGet]
        //public object UserList(string name = null)
        //{
        //    return DemoManager.GetData(name);
        //}


        public object UserList(int id,string name = null)
        {
            return id;
            //return DemoManager.GetData(name);
        }

        [NoLogin]
        public object Get()
        {
            var user = User;
            return DemoManager.Get();
        }


        public object Login(string name,string password)
        {
            if (User.IsAuthenticated == false)
            {
                return new StringResult("登陆失败！");
            }
            // TODO 
            //return Redirect("index.html");
            return null;
        }

        [NoLogin]
        public object Test(int buildingKid)
        {
            //Task<T_Building> build = BuildingManager.GetBuilding(buildingKid);
            //if (build.Result.F_IsTest == 1)
            //{
            //    return 1;
            //}
            return 0;

            //return BuildingManager.GetBuilding(buildingKid);
        }       

        [NoLogin]
        public object PointMainOAuth()
        {
            return DemoManager.UpdateMiss();
        }


        [NoLogin]
        public object SetModel(string model = "close")
        {
            Configs.AppSettings.Set("BigTurnTableModel", model);
            return Configs.AppSettings.Get("BigTurnTableModel");
        }
        [NoLogin]
        public object InitProductShow()
        {
            MemoryTable.Init_ProductShow_table().Wait();
            return 1;
        }

        [NoLogin]
        public object InitPointMain()
        {
            MemoryTable.Init_PointMain_table().Wait();
            return 1;
        }

        [NoLogin]
        public object Lasting()
        {
            return 1;
        }

        [NoLogin]
        public object LookBigTurnInfo()
        {
            return LuckBigWheel.luckyQueuelook;
        }

        [NoLogin]
        public tests x()
        {
            return new tests()
            {
                a = 1,
                b = "123"
            };
        }
    }
    public class tests
    {
        public int a { get; set; }

        public string b { get; set; }
    }
}
